diff --git a/static/app/views/automations/components/editConnectedMonitors.spec.tsx b/static/app/views/automations/components/editConnectedMonitors.spec.tsx index 3e311a88077b4f..aec7c0a996cbd7 100644 --- a/static/app/views/automations/components/editConnectedMonitors.spec.tsx +++ b/static/app/views/automations/components/editConnectedMonitors.spec.tsx @@ -1,4 +1,5 @@ import {MetricDetectorFixture} from 'sentry-fixture/detectors'; +import {PageFiltersFixture} from 'sentry-fixture/pageFilters'; import { render, @@ -8,6 +9,8 @@ import { within, } from 'sentry-test/reactTestingLibrary'; +import PageFiltersStore from 'sentry/stores/pageFiltersStore'; + import EditConnectedMonitors from './editConnectedMonitors'; describe('EditConnectedMonitors', () => { @@ -26,6 +29,7 @@ describe('EditConnectedMonitors', () => { method: 'GET', body: [detector1], }); + PageFiltersStore.onInitializeUrlState(PageFiltersFixture({projects: [1]})); }); it('can connect an existing monitor', async () => { diff --git a/static/app/views/automations/components/editConnectedMonitors.tsx b/static/app/views/automations/components/editConnectedMonitors.tsx index f649cf01a1f46f..e087da81bc708d 100644 --- a/static/app/views/automations/components/editConnectedMonitors.tsx +++ b/static/app/views/automations/components/editConnectedMonitors.tsx @@ -5,6 +5,8 @@ import {Button} from 'sentry/components/core/button'; import {Flex} from 'sentry/components/core/layout'; import useDrawer from 'sentry/components/globalDrawer'; import {DrawerHeader} from 'sentry/components/globalDrawer/components'; +import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container'; +import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter'; import Pagination from 'sentry/components/pagination'; import {Container} from 'sentry/components/workflowEngine/ui/container'; import Section from 'sentry/components/workflowEngine/ui/section'; @@ -14,6 +16,7 @@ import type {Automation} from 'sentry/types/workflowEngine/automations'; import type {Detector} from 'sentry/types/workflowEngine/detectors'; import {getApiQueryData, setApiQueryData, useQueryClient} from 'sentry/utils/queryClient'; import useOrganization from 'sentry/utils/useOrganization'; +import usePageFilters from 'sentry/utils/usePageFilters'; import ConnectedMonitorsList from 'sentry/views/automations/components/connectedMonitorsList'; import {DetectorSearch} from 'sentry/views/detectors/components/detectorSearch'; import {makeDetectorListQueryKey, useDetectorsQuery} from 'sentry/views/detectors/hooks'; @@ -63,38 +66,50 @@ function AllMonitors({ }) { const [query, setQuery] = useState(''); const [cursor, setCursor] = useState(undefined); + const {selection, isReady} = usePageFilters(); const { data: monitors = [], isLoading, isError, getResponseHeader, - } = useDetectorsQuery({ - query, - cursor, - limit: 10, - }); + } = useDetectorsQuery( + { + query, + cursor, + limit: 10, + projects: selection.projects, + }, + {enabled: isReady} + ); return ( -
- - - -
{footerContent}
- +
+ + +
+ +
+
+ - -
+ +
{footerContent}
+ +
+
+ ); } @@ -189,6 +204,8 @@ export default function EditConnectedMonitors({connectedIds, setConnectedIds}: P ), { ariaLabel: t('Connect Monitors'), + shouldCloseOnLocationChange: nextLocation => + nextLocation.pathname !== window.location.pathname, shouldCloseOnInteractOutside: el => { if (!ref.current) { return true;