Skip to content

Commit

Permalink
[8.8] [RAM][Maintenance Window][8.8] Remove Extra Commas and Disable …
Browse files Browse the repository at this point in the history
…Fetch If No License (elastic#156296) (elastic#156573)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[RAM][Maintenance Window][8.8] Remove Extra Commas and Disable Fetch
If No License (elastic#156296)](elastic#156296)

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

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

<!--BACKPORT [{"author":{"name":"Jiawei
Wu","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-03T15:35:56Z","message":"[RAM][Maintenance
Window][8.8] Remove Extra Commas and Disable Fetch If No License
(elastic#156296)\n\n## Summary\r\n\r\nRemove some extra commas for the
maintenance window no license prompt
\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/74562234/235515841-1ea1da44-db5c-42c0-9e34-97ad017be474.png)\r\n\r\nAlso,
disable fetch if the user does not have the correct license
type,\r\nthis gets rid of the unnecessary error popover since the
find\r\nmaintenance window API will reject these requests.\r\n\r\n###
Checklist\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":"f7881f6658f1d7c65280482c047785ba5ea5c302","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","backport","release_note:skip","impact:low","Team:ResponseOps","Feature:Alerting/RulesManagement","v8.8.0","v8.9.0"],"number":156296,"url":"https://github.com/elastic/kibana/pull/156296","mergeCommit":{"message":"[RAM][Maintenance
Window][8.8] Remove Extra Commas and Disable Fetch If No License
(elastic#156296)\n\n## Summary\r\n\r\nRemove some extra commas for the
maintenance window no license prompt
\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/74562234/235515841-1ea1da44-db5c-42c0-9e34-97ad017be474.png)\r\n\r\nAlso,
disable fetch if the user does not have the correct license
type,\r\nthis gets rid of the unnecessary error popover since the
find\r\nmaintenance window API will reject these requests.\r\n\r\n###
Checklist\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":"f7881f6658f1d7c65280482c047785ba5ea5c302"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.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/156296","number":156296,"mergeCommit":{"message":"[RAM][Maintenance
Window][8.8] Remove Extra Commas and Disable Fetch If No License
(elastic#156296)\n\n## Summary\r\n\r\nRemove some extra commas for the
maintenance window no license prompt
\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/74562234/235515841-1ea1da44-db5c-42c0-9e34-97ad017be474.png)\r\n\r\nAlso,
disable fetch if the user does not have the correct license
type,\r\nthis gets rid of the unnecessary error popover since the
find\r\nmaintenance window API will reject these requests.\r\n\r\n###
Checklist\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":"f7881f6658f1d7c65280482c047785ba5ea5c302"}}]}]
BACKPORT-->

Co-authored-by: Jiawei Wu <[email protected]>
  • Loading branch information
kibanamachine and JiaweiWu authored May 3, 2023
1 parent 177ef15 commit 7ae26ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
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

0 comments on commit 7ae26ec

Please sign in to comment.