mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
92d91fdebc
* consistent error handling * Display server errors in InviteUserForm * Handle errors in Form component * Refactors query form * creates KolideAce component * Renders QueryForm from query page and manage hosts page * Moves ace editor and select targets dropdown to query form * Render base errors in Form HOC * LoginPage and ForgotPasswordPage server errors * Ensure unique key for user blocks * Adds base error to login form and forgot password form * Adds base error to query form * Adds base error to Pack Form * Adds errors to confirm invite form * Adds clearErrors action * clear errors when confirm invite page unmounts * Handle errors in the App Setting page * Handle server errors in the User Settings Page * Handle server errors in the User Management Page
41 lines
934 B
JavaScript
41 lines
934 B
JavaScript
const formChanged = (fields, query) => {
|
|
return query.name !== fields.name.value ||
|
|
query.description !== fields.description.value ||
|
|
query.query !== fields.query.value;
|
|
};
|
|
|
|
const canSaveAsNew = (fields, query = {}) => {
|
|
if (!fields.name.value && !fields.description.value) {
|
|
return true;
|
|
}
|
|
|
|
if (fields.name.value !== query.name) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
const canSaveChanges = (fields, query = {}) => {
|
|
if (!query.name && !query.description) {
|
|
return false;
|
|
}
|
|
|
|
if (formChanged(fields, query)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
const allPlatforms = { label: 'All Platforms', value: '' };
|
|
const platformOptions = [
|
|
allPlatforms,
|
|
{ label: 'macOS', value: 'darwin' },
|
|
{ label: 'Windows', value: 'windows' },
|
|
{ label: 'Ubuntu', value: 'ubuntu' },
|
|
{ label: 'Centos', value: 'centos' },
|
|
];
|
|
|
|
export default { allPlatforms, canSaveAsNew, canSaveChanges, platformOptions };
|