diff --git a/changes/46077-newly-created-reports-do-not-show-up b/changes/46077-newly-created-reports-do-not-show-up new file mode 100644 index 0000000000..8b8700b9ac --- /dev/null +++ b/changes/46077-newly-created-reports-do-not-show-up @@ -0,0 +1 @@ +* Fixed newly created or updated reports not appearing in the host details "Live report" modal or the reports list until a hard refresh. diff --git a/frontend/pages/hosts/details/HostDetailsPage/modals/SelectReportModal/SelectReportModal.tsx b/frontend/pages/hosts/details/HostDetailsPage/modals/SelectReportModal/SelectReportModal.tsx index 70ded6ad43..c9051bf82b 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/modals/SelectReportModal/SelectReportModal.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/modals/SelectReportModal/SelectReportModal.tsx @@ -64,7 +64,6 @@ const SelectReportModal = ({ ], ({ queryKey }) => queryAPI.loadAll(queryKey[0]), { - refetchOnMount: false, refetchOnReconnect: false, refetchOnWindowFocus: false, retry: false, diff --git a/frontend/pages/queries/edit/EditQueryPage.tsx b/frontend/pages/queries/edit/EditQueryPage.tsx index e2a447f994..fa5caa6fc6 100644 --- a/frontend/pages/queries/edit/EditQueryPage.tsx +++ b/frontend/pages/queries/edit/EditQueryPage.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useContext } from "react"; -import { useQuery } from "react-query"; +import { useQuery, useQueryClient } from "react-query"; import { useErrorHandler } from "react-error-boundary"; import { InjectedRouter, Params } from "react-router/lib/Router"; import { Location } from "history"; @@ -69,6 +69,7 @@ const EditQueryPage = ({ }); const handlePageError = useErrorHandler(); + const queryClient = useQueryClient(); const { isGlobalAdmin, isGlobalMaintainer, @@ -262,6 +263,7 @@ const EditQueryPage = ({ setIsQuerySaving(true); try { const { query } = await queryAPI.create(formData); + queryClient.invalidateQueries({ queryKey: [{ scope: "queries" }] }); notify.success("Report created."); router.push( getPathWithQueryParams(PATHS.REPORT_DETAILS(query.id), { @@ -313,6 +315,7 @@ const EditQueryPage = ({ try { await queryAPI.update(queryId, updatedQuery); + queryClient.invalidateQueries({ queryKey: [{ scope: "queries" }] }); notify.success("Report updated."); router.push( getPathWithQueryParams(PATHS.REPORT_DETAILS(queryId), {