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

[8.8] [RAM][Maintenance Window][8.8] Remove Extra Commas and Disable Fetch If No License (#156296) #156573

Merged
merged 2 commits into from
May 3, 2023
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 @@ -53,4 +53,12 @@ describe('useFindMaintenanceWindows', () => {
expect(mockAddDanger).toBeCalledWith('Unable to load maintenance windows.')
);
});

it('should not try to find maintenance windows if not enabled', async () => {
renderHook(() => useFindMaintenanceWindows({ enabled: false }), {
wrapper: appMockRenderer.AppWrapper,
});

await waitFor(() => expect(findMaintenanceWindows).toHaveBeenCalledTimes(0));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import { useQuery } from '@tanstack/react-query';
import { useKibana } from '../utils/kibana_react';
import { findMaintenanceWindows } from '../services/maintenance_windows_api/find';

export const useFindMaintenanceWindows = () => {
interface UseFindMaintenanceWindowsProps {
enabled?: boolean;
}

export const useFindMaintenanceWindows = (props?: UseFindMaintenanceWindowsProps) => {
const { enabled = true } = props || {};

const {
http,
notifications: { toasts },
Expand All @@ -32,6 +38,7 @@ export const useFindMaintenanceWindows = () => {

const {
isLoading,
isFetching,
data = [],
refetch,
} = useQuery({
Expand All @@ -41,11 +48,12 @@ export const useFindMaintenanceWindows = () => {
refetchOnWindowFocus: false,
retry: false,
cacheTime: 0,
enabled,
});

return {
maintenanceWindows: data,
isLoading,
isLoading: enabled && (isLoading || isFetching),
refetch,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const LicensePrompt = React.memo(() => {
>
{i18n.UPGRADE_SUBSCRIPTION}
</EuiButtonEmpty>
,
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
Expand All @@ -58,7 +57,6 @@ export const LicensePrompt = React.memo(() => {
>
{i18n.START_TRIAL}
</EuiButton>
,
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ export const MaintenanceWindowsPage = React.memo(() => {
docLinks,
} = useKibana().services;
const { isAtLeastPlatinum } = useLicense();
const hasLicense = isAtLeastPlatinum();

const { navigateToCreateMaintenanceWindow } = useCreateMaintenanceWindowNavigation();

const { isLoading, maintenanceWindows, refetch } = useFindMaintenanceWindows();
const { isLoading, maintenanceWindows, refetch } = useFindMaintenanceWindows({
enabled: hasLicense,
});

useBreadcrumbs(AlertingDeepLinkId.maintenanceWindows);

Expand All @@ -56,7 +59,6 @@ export const MaintenanceWindowsPage = React.memo(() => {
maintenanceWindows.length === 0 &&
showWindowMaintenance &&
writeWindowMaintenance;
const hasLicense = isAtLeastPlatinum();

const readOnly = showWindowMaintenance && !writeWindowMaintenance;

Expand Down