mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
UI: only setEditingExistingQuery in the edit query form if the query has been modified (#25115)
## #24653 - This bug was more generally that live query runs from the Edit query form did not include the `query_id` in the `run` API call.  - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
This commit is contained in:
parent
b1446b1ad8
commit
338a00a693
2 changed files with 15 additions and 1 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
- When running a live query from the edit query form, consider the results of the run in calculating
|
||||||
|
an existing query's performance impact if the user didn't change the query from the stored version.
|
||||||
|
|
@ -184,6 +184,7 @@ const EditQueryForm = ({
|
||||||
const [isEditingDescription, setIsEditingDescription] = useState(false);
|
const [isEditingDescription, setIsEditingDescription] = useState(false);
|
||||||
const [isSaveAsNewLoading, setIsSaveAsNewLoading] = useState(false);
|
const [isSaveAsNewLoading, setIsSaveAsNewLoading] = useState(false);
|
||||||
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
|
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
|
||||||
|
const [queryWasChanged, setQueryWasChanged] = useState(false);
|
||||||
|
|
||||||
const platformCompatibility = usePlatformCompatibility();
|
const platformCompatibility = usePlatformCompatibility();
|
||||||
const { setCompatiblePlatforms } = platformCompatibility;
|
const { setCompatiblePlatforms } = platformCompatibility;
|
||||||
|
|
@ -233,6 +234,7 @@ const EditQueryForm = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangeQuery = (sqlString: string) => {
|
const onChangeQuery = (sqlString: string) => {
|
||||||
|
setQueryWasChanged(true);
|
||||||
setLastEditedQueryBody(sqlString);
|
setLastEditedQueryBody(sqlString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -882,7 +884,17 @@ const EditQueryForm = ({
|
||||||
className={`${baseClass}__run`}
|
className={`${baseClass}__run`}
|
||||||
variant="blue-green"
|
variant="blue-green"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setEditingExistingQuery(true); // Persists edited query data through live query flow
|
// calling `setEditingExistingQuery` here prevents
|
||||||
|
// inclusion of `query_id` in the subsequent `run` API call, which prevents counting
|
||||||
|
// this live run in performance impact. Since we DO want to count this run in those
|
||||||
|
// stats if the query is the same as the saved one, only set below IF the query
|
||||||
|
// has been changed.
|
||||||
|
// TODO - product: should host details > action > query > <select existing query>
|
||||||
|
// go to the host details page instead of the edit query page, where the user has
|
||||||
|
// the choice to edit the query or run it live directly?
|
||||||
|
if (queryWasChanged) {
|
||||||
|
setEditingExistingQuery(true); // Persists edited query data through live query flow
|
||||||
|
}
|
||||||
router.push(
|
router.push(
|
||||||
PATHS.LIVE_QUERY(queryIdForEdit) +
|
PATHS.LIVE_QUERY(queryIdForEdit) +
|
||||||
TAGGED_TEMPLATES.queryByHostRoute(hostId, currentTeamId)
|
TAGGED_TEMPLATES.queryByHostRoute(hostId, currentTeamId)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue