mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.7`: - [Refresh the app after saving a monitor (#150733)](https://github.com/elastic/kibana/pull/150733) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Alejandro Fernández Gómez","email":"alejandro.fernandez@elastic.co"},"sourceCommit":{"committedDate":"2023-02-21T09:58:41Z","message":"Refresh the app after saving a monitor (#150733)\n\n## Summary\r\n\r\nCloses #150594\r\n\r\nEnsures the synthetics app refreshes its state when a monitor is\r\ncreated, no matter the method.\r\n\r\nThis mirrors how the [Simple monitor creation flow\r\nworks](3595849389/x-pack/plugins/synthetics/public/apps/synthetics/components/getting_started/use_simple_monitor.ts (L70-L71)
)","sha":"8feaf6f4d5146bd27f97fb9703998178bf19eb6e","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:uptime","release_note:skip","v8.7.0","v8.8.0"],"number":150733,"url":"https://github.com/elastic/kibana/pull/150733","mergeCommit":{"message":"Refresh the app after saving a monitor (#150733)\n\n## Summary\r\n\r\nCloses #150594\r\n\r\nEnsures the synthetics app refreshes its state when a monitor is\r\ncreated, no matter the method.\r\n\r\nThis mirrors how the [Simple monitor creation flow\r\nworks](3595849389/x-pack/plugins/synthetics/public/apps/synthetics/components/getting_started/use_simple_monitor.ts (L70-L71)
)","sha":"8feaf6f4d5146bd27f97fb9703998178bf19eb6e"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150733","number":150733,"mergeCommit":{"message":"Refresh the app after saving a monitor (#150733)\n\n## Summary\r\n\r\nCloses #150594\r\n\r\nEnsures the synthetics app refreshes its state when a monitor is\r\ncreated, no matter the method.\r\n\r\nThis mirrors how the [Simple monitor creation flow\r\nworks](3595849389/x-pack/plugins/synthetics/public/apps/synthetics/components/getting_started/use_simple_monitor.ts (L70-L71)
)","sha":"8feaf6f4d5146bd27f97fb9703998178bf19eb6e"}}]}] BACKPORT--> Co-authored-by: Alejandro Fernández Gómez <alejandro.fernandez@elastic.co>
This commit is contained in:
parent
4fcef5cd8f
commit
65b4e6cd11
2 changed files with 10 additions and 2 deletions
|
@ -8,13 +8,18 @@
|
|||
import { FETCH_STATUS, useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useParams, useRouteMatch } from 'react-router-dom';
|
||||
import { useEffect } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { MONITOR_EDIT_ROUTE } from '../../../../../../common/constants';
|
||||
import { SyntheticsMonitor } from '../../../../../../common/runtime_types';
|
||||
import { createMonitorAPI, updateMonitorAPI } from '../../../state/monitor_management/api';
|
||||
import { kibanaService } from '../../../../../utils/kibana_service';
|
||||
import { cleanMonitorListState } from '../../../state';
|
||||
import { useSyntheticsRefreshContext } from '../../../contexts';
|
||||
|
||||
export const useMonitorSave = ({ monitorData }: { monitorData?: SyntheticsMonitor }) => {
|
||||
const dispatch = useDispatch();
|
||||
const { refreshApp } = useSyntheticsRefreshContext();
|
||||
const { monitorId } = useParams<{ monitorId: string }>();
|
||||
|
||||
const editRouteMatch = useRouteMatch({ path: MONITOR_EDIT_ROUTE });
|
||||
|
@ -42,12 +47,14 @@ export const useMonitorSave = ({ monitorData }: { monitorData?: SyntheticsMonito
|
|||
toastLifeTimeMs: 3000,
|
||||
});
|
||||
} else if (status === FETCH_STATUS.SUCCESS && !loading) {
|
||||
refreshApp();
|
||||
dispatch(cleanMonitorListState());
|
||||
kibanaService.toasts.addSuccess({
|
||||
title: monitorId ? MONITOR_UPDATED_SUCCESS_LABEL : MONITOR_SUCCESS_LABEL,
|
||||
toastLifeTimeMs: 3000,
|
||||
});
|
||||
}
|
||||
}, [data, status, monitorId, loading]);
|
||||
}, [data, status, monitorId, loading, refreshApp, dispatch]);
|
||||
|
||||
return { status, loading, isEdit };
|
||||
};
|
||||
|
|
|
@ -56,6 +56,7 @@ export const OverviewPage: React.FC = () => {
|
|||
} = useEnablement();
|
||||
|
||||
const {
|
||||
loaded: overviewLoaded,
|
||||
data: { monitors },
|
||||
pageState,
|
||||
} = useSelector(selectOverviewState);
|
||||
|
@ -94,7 +95,7 @@ export const OverviewPage: React.FC = () => {
|
|||
return <Redirect to={MONITORS_ROUTE} />;
|
||||
}
|
||||
|
||||
const noMonitorFound = monitorsLoaded && monitors?.length === 0;
|
||||
const noMonitorFound = monitorsLoaded && overviewLoaded && monitors?.length === 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue