mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* 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
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
import Kolide from 'kolide';
|
|
|
|
import formatApiErrors from 'utilities/format_api_errors';
|
|
import { frontendFormattedConfig } from 'redux/nodes/app/helpers';
|
|
|
|
export const CONFIG_FAILURE = 'CONFIG_FAILURE';
|
|
export const CONFIG_START = 'CONFIG_START';
|
|
export const CONFIG_SUCCESS = 'CONFIG_SUCCESS';
|
|
export const SHOW_BACKGROUND_IMAGE = 'SHOW_BACKGROUND_IMAGE';
|
|
export const HIDE_BACKGROUND_IMAGE = 'HIDE_BACKGROUND_IMAGE';
|
|
|
|
export const showBackgroundImage = {
|
|
type: SHOW_BACKGROUND_IMAGE,
|
|
};
|
|
export const hideBackgroundImage = {
|
|
type: HIDE_BACKGROUND_IMAGE,
|
|
};
|
|
export const configFailure = (error) => {
|
|
return { type: CONFIG_FAILURE, payload: { error } };
|
|
};
|
|
export const loadConfig = { type: CONFIG_START };
|
|
export const configSuccess = (data) => {
|
|
return { type: CONFIG_SUCCESS, payload: { data } };
|
|
};
|
|
export const getConfig = () => {
|
|
return (dispatch) => {
|
|
dispatch(loadConfig);
|
|
|
|
return Kolide.getConfig()
|
|
.then((config) => {
|
|
const formattedConfig = frontendFormattedConfig(config);
|
|
|
|
dispatch(configSuccess(formattedConfig));
|
|
|
|
return formattedConfig;
|
|
})
|
|
.catch((error) => {
|
|
const formattedErrors = formatApiErrors(error);
|
|
|
|
dispatch(configFailure(formattedErrors));
|
|
|
|
throw error;
|
|
});
|
|
};
|
|
};
|
|
export const updateConfig = (configData) => {
|
|
return (dispatch) => {
|
|
dispatch(loadConfig);
|
|
|
|
return Kolide.updateConfig(configData)
|
|
.then((config) => {
|
|
const formattedConfig = frontendFormattedConfig(config);
|
|
|
|
dispatch(configSuccess(formattedConfig));
|
|
|
|
return formattedConfig;
|
|
})
|
|
.catch((error) => {
|
|
const formattedErrors = formatApiErrors(error);
|
|
|
|
dispatch(configFailure(formattedErrors));
|
|
|
|
throw error;
|
|
});
|
|
};
|
|
};
|