Fleet UI: (Unreleased bug) Redirect to query editor on creating a new query (#12870)

## Issue
Unreleased bug #12857 

## Description
Clean up create call so we can easily go to the newly created query
using the newly created query id

## QA
- Rachel and @jacobshandling tested this on the fullstack branch already
and works great
NOTE: Reed should still test :) 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Manual QA for all new/changed functionality
This commit is contained in:
RachelElysia 2023-07-20 14:38:58 -04:00 committed by GitHub
parent 53bad0b398
commit 87a7a508a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 15 deletions

View file

@ -13,7 +13,6 @@ import { IHost, IHostResponse } from "interfaces/host";
import { ILabel } from "interfaces/label";
import { ITeam } from "interfaces/team";
import {
ICreateQueryRequestBody,
IGetQueryResponse,
ISchedulableQuery,
} from "interfaces/schedulable_query";
@ -143,12 +142,6 @@ const QueryPage = ({
}
);
const {
mutateAsync: createQuery,
} = useMutation((formData: ICreateQueryRequestBody) =>
queryAPI.create(formData)
);
const detectIsFleetQueryRunnable = () => {
statusAPI.live_query().catch(() => {
setIsLiveQueryRunnable(false);
@ -221,7 +214,6 @@ const QueryPage = ({
storedQuery,
isStoredQueryLoading,
storedQueryError,
createQuery,
onOsqueryTableSelect,
goToSelectTargets: () => setStep(QUERIES_PAGE_STEPS[2]),
onOpenSchemaSidebar,

View file

@ -28,11 +28,6 @@ interface IQueryEditorProps {
storedQueryError: Error | null;
showOpenSchemaActionText: boolean;
isStoredQueryLoading: boolean;
createQuery: UseMutateAsyncFunction<
ISchedulableQuery,
unknown,
ICreateQueryRequestBody
>;
onOsqueryTableSelect: (tableName: string) => void;
goToSelectTargets: () => void;
onOpenSchemaSidebar: () => void;
@ -49,7 +44,6 @@ const QueryEditor = ({
storedQueryError,
showOpenSchemaActionText,
isStoredQueryLoading,
createQuery,
onOsqueryTableSelect,
goToSelectTargets,
onOpenSchemaSidebar,
@ -90,7 +84,7 @@ const QueryEditor = ({
const saveQuery = debounce(async (formData: ICreateQueryRequestBody) => {
setIsQuerySaving(true);
try {
const query = await createQuery(formData);
const { query } = await queryAPI.create(formData);
router.push(PATHS.EDIT_QUERY(query.id));
renderFlash("success", "Query created!");
setBackendValidators({});