mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
* 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
42 lines
900 B
JavaScript
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 };
|