[8.8] [Security Solutions] Fix install azure integration URL and loading state (#155706) (#156262)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Security Solutions] Fix install azure integration URL and loading
state (#155706)](https://github.com/elastic/kibana/pull/155706)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Pablo
Machado","email":"pablo.nevesmachado@elastic.co"},"sourceCommit":{"committedDate":"2023-05-01T14:09:25Z","message":"[Security
Solutions] Fix install azure integration URL and loading state
(#155706)\n\n## Summary\r\n\r\n* Generate Azure integration URL instead
of hardcoding it
\r\n\r\n![Apr-26-2023\r\n14-32-40](https://user-images.githubusercontent.com/1490444/234575705-6ff288c3-5691-4b66-af6c-cf1383f3399b.gif)\r\n\r\n*
Fix flyout showing callout when
loading\r\n\r\n![Apr-26-2023\r\n14-25-10](https://user-images.githubusercontent.com/1490444/234574219-ed25f37b-0206-49d6-bc81-8d75cf023e64.gif)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"23d47b7d105ee285c58dda20958984e5a3030515","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","v8.0.0","release_note:skip","Team:Threat
Hunting","Team: SecuritySolution","Team:Threat
Hunting:Explore","v8.9.0"],"number":155706,"url":"https://github.com/elastic/kibana/pull/155706","mergeCommit":{"message":"[Security
Solutions] Fix install azure integration URL and loading state
(#155706)\n\n## Summary\r\n\r\n* Generate Azure integration URL instead
of hardcoding it
\r\n\r\n![Apr-26-2023\r\n14-32-40](https://user-images.githubusercontent.com/1490444/234575705-6ff288c3-5691-4b66-af6c-cf1383f3399b.gif)\r\n\r\n*
Fix flyout showing callout when
loading\r\n\r\n![Apr-26-2023\r\n14-25-10](https://user-images.githubusercontent.com/1490444/234574219-ed25f37b-0206-49d6-bc81-8d75cf023e64.gif)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"23d47b7d105ee285c58dda20958984e5a3030515"}},"sourceBranch":"main","suggestedTargetBranches":["8.0"],"targetPullRequestStates":[{"branch":"8.0","label":"v8.0.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/155706","number":155706,"mergeCommit":{"message":"[Security
Solutions] Fix install azure integration URL and loading state
(#155706)\n\n## Summary\r\n\r\n* Generate Azure integration URL instead
of hardcoding it
\r\n\r\n![Apr-26-2023\r\n14-32-40](https://user-images.githubusercontent.com/1490444/234575705-6ff288c3-5691-4b66-af6c-cf1383f3399b.gif)\r\n\r\n*
Fix flyout showing callout when
loading\r\n\r\n![Apr-26-2023\r\n14-25-10](https://user-images.githubusercontent.com/1490444/234574219-ed25f37b-0206-49d6-bc81-8d75cf023e64.gif)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"23d47b7d105ee285c58dda20958984e5a3030515"}}]}]
BACKPORT-->

Co-authored-by: Pablo Machado <pablo.nevesmachado@elastic.co>
This commit is contained in:
Kibana Machine 2023-05-02 08:42:10 -04:00 committed by GitHub
parent b8073f5b73
commit 99887680e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 5 deletions

View file

@ -7,6 +7,6 @@
export const MANAGED_USER_INDEX = ['logs-entityanalytics_azure.users-*'];
export const MANAGED_USER_PACKAGE_NAME = 'entityanalytics_azure';
export const INSTALL_INTEGRATION_HREF = `/app/fleet/integrations/${MANAGED_USER_PACKAGE_NAME}/add-integration`;
export const INSTALL_INTEGRATION_HREF = `/detail/${MANAGED_USER_PACKAGE_NAME}/overview`;
export const ONE_WEEK_IN_HOURS = 24 * 7;
export const MANAGED_USER_QUERY_ID = 'managedUserDetailsQuery';

View file

@ -117,7 +117,7 @@ export const useManagedUser = (userName: string) => {
}
}, [from, search, to, userName, isInitializing]);
const { data: installedIntegrations } = useInstalledIntegrations({
const { data: installedIntegrations, isLoading: loadingIntegrations } = useInstalledIntegrations({
packages: [MANAGED_USER_PACKAGE_NAME],
});
@ -156,7 +156,7 @@ export const useManagedUser = (userName: string) => {
return useMemo(
() => ({
details: managedUserDetails,
isLoading: loadingManagedUser,
isLoading: loadingManagedUser || loadingIntegrations,
isIntegrationEnabled,
firstSeen: {
date: firstSeen,
@ -167,6 +167,7 @@ export const useManagedUser = (userName: string) => {
[
firstSeen,
isIntegrationEnabled,
loadingIntegrations,
lastSeen,
loadingFirstSeen,
loadingLastSeen,

View file

@ -78,4 +78,34 @@ describe('ManagedUser', () => {
expect(getByTestId('managedUser-data')).toHaveTextContent('123456, 654321');
});
it('it renders the call out when the integration is disabled', () => {
const { queryByTestId } = render(
<TestProviders>
<ManagedUser
{...{
...mockProps,
managedUser: { ...mockManagedUser, isIntegrationEnabled: false },
}}
/>
</TestProviders>
);
expect(queryByTestId('managedUser-integration-disable-callout')).toBeInTheDocument();
});
it("it doesn't show the call out when the user is loading", () => {
const { queryByTestId } = render(
<TestProviders>
<ManagedUser
{...{
...mockProps,
managedUser: { ...mockManagedUser, isLoading: true, isIntegrationEnabled: false },
}}
/>
</TestProviders>
);
expect(queryByTestId('managedUser-integration-disable-callout')).not.toBeInTheDocument();
});
});

View file

@ -29,6 +29,7 @@ import { FormattedRelativePreferenceDate } from '../../../../common/components/f
import type { ManagedUserData } from './types';
import { INSTALL_INTEGRATION_HREF, MANAGED_USER_QUERY_ID, ONE_WEEK_IN_HOURS } from './constants';
import { InspectButton, InspectButtonContainer } from '../../../../common/components/inspect';
import { useAppUrl } from '../../../../common/lib/kibana';
export const ManagedUser = ({
managedUser,
@ -49,8 +50,14 @@ export const ManagedUser = ({
() => getManagedUserTableColumns(contextID, isDraggable),
[isDraggable, contextID]
);
const { getAppUrl } = useAppUrl();
if (!managedUser.isIntegrationEnabled) {
const installedIntegrationHref = useMemo(
() => getAppUrl({ appId: 'integrations', path: INSTALL_INTEGRATION_HREF }),
[getAppUrl]
);
if (!managedUser.isLoading && !managedUser.isIntegrationEnabled) {
return (
<>
<EuiTitle size="s">
@ -62,7 +69,7 @@ export const ManagedUser = ({
title={<h2>{i18n.NO_ACTIVE_INTEGRATION_TITLE}</h2>}
body={<p>{i18n.NO_ACTIVE_INTEGRATION_TEXT}</p>}
actions={
<EuiButton fill href={INSTALL_INTEGRATION_HREF}>
<EuiButton fill href={installedIntegrationHref}>
{i18n.ADD_EXTERNAL_INTEGRATION_BUTTON}
</EuiButton>
}