Skip to content

Commit

Permalink
Fix UI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Nov 29, 2024
1 parent de00917 commit 1196c6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,18 @@ export const useStopEntityEngineMutation = (options?: UseMutationOptions<{}>) =>
};

export const DELETE_ENTITY_ENGINE_STATUS_KEY = ['POST', 'STOP_ENTITY_ENGINE'];
export const useDeleteEntityEngineMutation = (options?: UseMutationOptions<{}>) => {
export const useDeleteEntityEngineMutation = ({ onSuccess }: { onSuccess?: () => void }) => {
const queryClient = useQueryClient();
const { deleteEntityEngine } = useEntityStoreRoutes();

return useMutation<DeleteEntityEngineResponse[]>(
() => Promise.all([deleteEntityEngine('user', true), deleteEntityEngine('host', true)]),
{
mutationKey: DELETE_ENTITY_ENGINE_STATUS_KEY,
onSuccess: () => queryClient.refetchQueries({ queryKey: ENTITY_STORE_STATUS }),
...options,
onSuccess: () => {
queryClient.refetchQueries({ queryKey: ENTITY_STORE_STATUS });
onSuccess?.();
},
}
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
EuiButtonEmpty,
} from '@elastic/eui';
import type { ReactNode } from 'react';
import React, { useCallback, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';

import type { SecurityAppError } from '@kbn/securitysolution-t-grid';
Expand Down Expand Up @@ -100,6 +100,15 @@ export const EntityStoreManagementPage = () => {

const { data: privileges } = useEntityEnginePrivileges();

const shouldDisplayEngineStatusTab =
isEntityStoreInstalled(entityStoreStatus.data?.status) && privileges?.has_all_required;

useEffect(() => {
if (selectedTabId === TabId.Status && !shouldDisplayEngineStatusTab) {
setSelectedTabId(TabId.Import);
}
}, [shouldDisplayEngineStatusTab, selectedTabId]);

if (assetCriticalityIsLoading) {
// Wait for permission before rendering content to avoid flickering
return null;
Expand Down Expand Up @@ -202,7 +211,7 @@ export const EntityStoreManagementPage = () => {
/>
</EuiTab>

{isEntityStoreInstalled(entityStoreStatus.data?.status) && privileges?.has_all_required && (
{shouldDisplayEngineStatusTab && (
<EuiTab
key={TabId.Status}
isSelected={selectedTabId === TabId.Status}
Expand Down

0 comments on commit 1196c6d

Please sign in to comment.