mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Synthetics] Improve toast information for add/update monitor (#155319)
This commit is contained in:
parent
755ddfe9cd
commit
24a3df49f8
1 changed files with 25 additions and 2 deletions
|
@ -6,8 +6,9 @@
|
|||
*/
|
||||
|
||||
import { FETCH_STATUS, useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { toMountPoint, useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useParams, useRouteMatch } from 'react-router-dom';
|
||||
import { useEffect } from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { MONITOR_EDIT_ROUTE } from '../../../../../../common/constants';
|
||||
|
@ -18,6 +19,8 @@ import { cleanMonitorListState } from '../../../state';
|
|||
import { useSyntheticsRefreshContext } from '../../../contexts';
|
||||
|
||||
export const useMonitorSave = ({ monitorData }: { monitorData?: SyntheticsMonitor }) => {
|
||||
const core = useKibana();
|
||||
const theme$ = core.services.theme?.theme$;
|
||||
const dispatch = useDispatch();
|
||||
const { refreshApp } = useSyntheticsRefreshContext();
|
||||
const { monitorId } = useParams<{ monitorId: string }>();
|
||||
|
@ -51,10 +54,16 @@ export const useMonitorSave = ({ monitorData }: { monitorData?: SyntheticsMonito
|
|||
dispatch(cleanMonitorListState());
|
||||
kibanaService.toasts.addSuccess({
|
||||
title: monitorId ? MONITOR_UPDATED_SUCCESS_LABEL : MONITOR_SUCCESS_LABEL,
|
||||
text: toMountPoint(
|
||||
<p data-test-subj="synthetcsMonitorSaveSubtext">
|
||||
{monitorId ? MONITOR_UPDATED_SUCCESS_LABEL_SUBTEXT : MONITOR_SUCCESS_LABEL_SUBTEXT}
|
||||
</p>,
|
||||
{ theme$ }
|
||||
),
|
||||
toastLifeTimeMs: 3000,
|
||||
});
|
||||
}
|
||||
}, [data, status, monitorId, loading, refreshApp, dispatch]);
|
||||
}, [data, status, monitorId, loading, refreshApp, dispatch, theme$]);
|
||||
|
||||
return { status, loading, isEdit };
|
||||
};
|
||||
|
@ -66,6 +75,13 @@ const MONITOR_SUCCESS_LABEL = i18n.translate(
|
|||
}
|
||||
);
|
||||
|
||||
const MONITOR_SUCCESS_LABEL_SUBTEXT = i18n.translate(
|
||||
'xpack.synthetics.monitorManagement.monitorAddedSuccessMessage.subtext',
|
||||
{
|
||||
defaultMessage: 'It will next run according to its defined schedule.',
|
||||
}
|
||||
);
|
||||
|
||||
const MONITOR_UPDATED_SUCCESS_LABEL = i18n.translate(
|
||||
'xpack.synthetics.monitorManagement.monitorEditedSuccessMessage',
|
||||
{
|
||||
|
@ -79,3 +95,10 @@ const MONITOR_FAILURE_LABEL = i18n.translate(
|
|||
defaultMessage: 'Monitor was unable to be saved. Please try again later.',
|
||||
}
|
||||
);
|
||||
|
||||
const MONITOR_UPDATED_SUCCESS_LABEL_SUBTEXT = i18n.translate(
|
||||
'xpack.synthetics.monitorManagement.monitorFailureMessage.subtext',
|
||||
{
|
||||
defaultMessage: 'It will next run according to its defined schedule.',
|
||||
}
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue