mirror of
https://github.com/fleetdm/fleet
synced 2026-05-17 22:18:39 +00:00
* API call to create queries * Add queries to redux * create query when query form is submitted * Redirect to ShowQueryPage after creating query * Removes theme dropdown and NewQuery component header * Extract NewQueryPage component state to redux state * Pass logic down to NewQuery component as props * Changes NewQuery component name to QueryComposer * Render NewQueryPage for /queries/:id route * Update ReduxConfig for loading a single resource * QueryPage tests * Get query when the query page loads * catch errors when query is invalid * Renames UpdateQueryForm to QueryForm to re-usability * Changes InputField to a controlled component * Always render the Query Form on Query Pages
33 lines
605 B
JavaScript
33 lines
605 B
JavaScript
import { isEmpty } from 'lodash';
|
|
|
|
const formChanged = (formData, query) => {
|
|
return formData.name !== query.name ||
|
|
formData.description !== query.description ||
|
|
formData.queryText !== query.query;
|
|
};
|
|
|
|
const canSaveAsNew = (formData, query) => {
|
|
if (isEmpty(query)) {
|
|
return true;
|
|
}
|
|
|
|
if (formData.name !== query.name) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
const canSaveChanges = (formData, query) => {
|
|
if (isEmpty(query)) {
|
|
return false;
|
|
}
|
|
|
|
if (formChanged(formData, query)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
export default { canSaveAsNew, canSaveChanges };
|