mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.8`: - [[Synthetics] Prevent location id query param on form (#156661)](https://github.com/elastic/kibana/pull/156661) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2023-05-05T16:07:07Z","message":"[Synthetics] Prevent location id query param on form (#156661)","sha":"4b0de666de4c9e794b2df78d4dc49619ceb230ef","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:uptime","release_note:skip","v8.8.0","v8.9.0"],"number":156661,"url":"https://github.com/elastic/kibana/pull/156661","mergeCommit":{"message":"[Synthetics] Prevent location id query param on form (#156661)","sha":"4b0de666de4c9e794b2df78d4dc49619ceb230ef"}},"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/156661","number":156661,"mergeCommit":{"message":"[Synthetics] Prevent location id query param on form (#156661)","sha":"4b0de666de4c9e794b2df78d4dc49619ceb230ef"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
This commit is contained in:
parent
012b92b67c
commit
8e6af8b489
3 changed files with 14 additions and 7 deletions
|
@ -16,18 +16,24 @@ interface Props {
|
|||
name: string;
|
||||
configId: string;
|
||||
locationId?: string;
|
||||
updateUrl?: boolean;
|
||||
}
|
||||
|
||||
export const MonitorDetailsLinkPortal = ({ name, configId, locationId }: Props) => {
|
||||
export const MonitorDetailsLinkPortal = ({ name, configId, locationId, updateUrl }: Props) => {
|
||||
return (
|
||||
<InPortal node={MonitorDetailsLinkPortalNode}>
|
||||
<MonitorDetailsLink name={name} configId={configId} locationId={locationId} />
|
||||
<MonitorDetailsLink
|
||||
name={name}
|
||||
configId={configId}
|
||||
locationId={locationId}
|
||||
updateUrl={updateUrl}
|
||||
/>
|
||||
</InPortal>
|
||||
);
|
||||
};
|
||||
|
||||
export const MonitorDetailsLink = ({ name, configId, locationId }: Props) => {
|
||||
const selectedLocation = useSelectedLocation();
|
||||
export const MonitorDetailsLink = ({ name, configId, locationId, updateUrl }: Props) => {
|
||||
const selectedLocation = useSelectedLocation(updateUrl);
|
||||
|
||||
let locId = locationId;
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ export const MonitorEditPage: React.FC = () => {
|
|||
<MonitorDetailsLinkPortal
|
||||
configId={data?.attributes[ConfigKey.CONFIG_ID]}
|
||||
name={data?.attributes.name}
|
||||
updateUrl={false}
|
||||
/>
|
||||
</MonitorForm>
|
||||
</>
|
||||
|
|
|
@ -10,7 +10,7 @@ import { useDispatch, useSelector } from 'react-redux';
|
|||
import { selectSelectedLocationId, setMonitorDetailsLocationAction } from '../../../state';
|
||||
import { useUrlParams, useLocations } from '../../../hooks';
|
||||
|
||||
export const useSelectedLocation = () => {
|
||||
export const useSelectedLocation = (updateUrl = true) => {
|
||||
const [getUrlParams, updateUrlParams] = useUrlParams();
|
||||
const { locations } = useLocations();
|
||||
const selectedLocationId = useSelector(selectSelectedLocationId);
|
||||
|
@ -21,7 +21,7 @@ export const useSelectedLocation = () => {
|
|||
useEffect(() => {
|
||||
if (!urlLocationId) {
|
||||
const firstLocationId = locations?.[0]?.id;
|
||||
if (firstLocationId) {
|
||||
if (firstLocationId && updateUrl) {
|
||||
updateUrlParams({ locationId: firstLocationId }, true);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export const useSelectedLocation = () => {
|
|||
if (urlLocationId && selectedLocationId !== urlLocationId) {
|
||||
dispatch(setMonitorDetailsLocationAction(urlLocationId));
|
||||
}
|
||||
}, [dispatch, updateUrlParams, locations, urlLocationId, selectedLocationId]);
|
||||
}, [dispatch, updateUrlParams, locations, urlLocationId, selectedLocationId, updateUrl]);
|
||||
|
||||
return useMemo(
|
||||
() => locations.find((loc) => loc.id === urlLocationId) ?? null,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue