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

[Security Solution] fix flashing authz on endpoint integration #130933

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,16 @@ describe('When displaying the EndpointPackageCustomExtension fleet UI extension'
expect(renderResult.queryByTestId('hostIsolationExceptions-fleetCard')).toBeNull();
});
});

it('should only show loading spinner if loading', () => {
useEndpointPrivilegesMock.mockReturnValue({
...getEndpointPrivilegesInitialStateMock(),
loading: true,
});
render();

expect(renderResult.getByTestId('endpointExtensionLoadingSpinner')).toBeInTheDocument();
expect(renderResult.queryByTestId('fleetEndpointPackageCustomContent')).toBeNull();
expect(renderResult.queryByTestId('noIngestPermissions')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { memo, useMemo } from 'react';
import { EuiSpacer } from '@elastic/eui';
import { EuiSpacer, EuiLoadingSpinner } from '@elastic/eui';
import { PackageCustomExtensionComponentProps } from '@kbn/fleet-plugin/public';
import { useHttp } from '../../../../../../common/lib/kibana';
import { useCanSeeHostIsolationExceptionsMenu } from '../../../../host_isolation_exceptions/view/hooks';
Expand Down Expand Up @@ -34,7 +34,7 @@ export const EndpointPackageCustomExtension = memo<PackageCustomExtensionCompone
(props) => {
const http = useHttp();
const canSeeHostIsolationExceptions = useCanSeeHostIsolationExceptionsMenu();
const { canAccessEndpointManagement } = useEndpointPrivileges();
const { loading, canAccessEndpointManagement } = useEndpointPrivileges();

const trustedAppsApiClientInstance = useMemo(
() => TrustedAppsApiClient.getInstance(http),
Expand Down Expand Up @@ -106,7 +106,13 @@ export const EndpointPackageCustomExtension = memo<PackageCustomExtensionCompone
]
);

return canAccessEndpointManagement ? artifactCards : <NoPermissions />;
return loading ? (
<EuiLoadingSpinner data-test-subj="endpointExtensionLoadingSpinner" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you try using our Management loader instead? Not sure how it will looks under the advanced tab but it should put the loader in the middle of the empty page.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dasansol92 We have some code in that component to center the loader on the page because its mean to really be used inside of an entire page.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true, good point!

) : canAccessEndpointManagement ? (
artifactCards
) : (
<NoPermissions />
);
}
);

Expand Down