fleet/frontend/components/forms/queries/QueryForm/helpers.js
Mike Stone bb62993ea5 Hosts side panel (#472)
* Host side panel

* Query form handles labels

* QueryComposer handles labels

* ManageHostsPage add label transitions

* Stop preventing default on click outside of ellipsis menu

* get labels from API

* use real label data in hosts side panel

* create label on label form submit

* adds platform dropdown

* Validate query text

* Label header

* validate presence of query text
2016-11-17 12:12:41 -05:00

42 lines
900 B
JavaScript

import { isEmpty } from 'lodash';
const formChanged = (formData, query) => {
return formData.name !== query.name ||
formData.description !== query.description ||
formData.query !== 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;
};
const allPlatforms = { label: 'All Platforms', value: '' };
const platformOptions = [
allPlatforms,
{ label: 'mac OS', value: 'darwin' },
{ label: 'Windows', value: 'windows' },
{ label: 'Ubuntu', value: 'ubuntu' },
{ label: 'Centos', value: 'centos' },
];
export default { allPlatforms, canSaveAsNew, canSaveChanges, platformOptions };