Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Detections] Better toast errors #72205

Merged
merged 11 commits into from
Jul 17, 2020

Commits on Jul 16, 2020

  1. Add new hook to wrap the toasts service

    When receiving error responses from our APIs, this gives us better toast
    messages.
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    81e70e3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    28095e6 View commit details
    Browse the repository at this point in the history
  3. WIP: prevent infinite polling when server is unresponsive

    The crux of this issue was that we had no steady state when the server
    returned a non-API error (!isApiError), as it would if the server was
    throwing 500s or just generally misbehaving.
    
    The solution, then, is to addresse these non-API errors in our
    underlying useListsIndex and useListsPrivileges hooks.
    
    This also refactors those hooks to:
    
    * collapse multiple error states into one (that's all we currently need)
    * use useAppToasts for better UI
    
    TODO: I don't think I need the changes in useListsConfig's useEffect.
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    940c54b View commit details
    Browse the repository at this point in the history
  4. Slightly more legible variables

    The only task in this hook is our readPrivileges task right now, so I'm
    shortening the variable until we have a need to disambiguate it further.
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    beefe5b View commit details
    Browse the repository at this point in the history
  5. Remove unnecessary conditions around creating our index

    If the index hook has an error needsIndex will not be true.
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    24ae1f5 View commit details
    Browse the repository at this point in the history
  6. Better toast errors for Kibana API errors

    Our isApiError predicate does not work for errors coming back from
    Kibana platform itself, e.g. for a request payload error.
    
    I've added a separate predicate for that case, isKibanaError, and then a
    wrapping isAppError predicate since most of our use cases just care
    about error.body.message, which is common to both.
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    f78d9bb View commit details
    Browse the repository at this point in the history
  7. Use new toasts hook on our exceptions modals

    This fixes two issues:
    
    * toast appears above modal overlay
    * Error message from response is now presented in the toast
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    3dd2fd4 View commit details
    Browse the repository at this point in the history
  8. Fix bug with toasts dependencies

    Because of the way some of the exception modal's hooks are written, a
    change to one of its callbacks means that the request will be canceled.
    
    Because the toasts service exports instance methods, the context within
    the function (and thus the function itself) can change leading to a
    mutable ref.
    
    Because we don't want/need this behavior, we store our exported
    functions in refs to 'freeze' them for react.
    
    With our bound functions, we should now be able to declare e.g.
    `toast.addError` as a dependency, however react cannot determine that it
    is bound (and thus that toast.addError() is equivalent to addError()),
    and so we must destructure our functions in order to use them as
    dependencies.
    rylnd committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    b755361 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2020

  1. Alert clipboard toasts through new Toasts service

    This fixes the z-index issue between modals and toasts.
    rylnd committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    59f36a9 View commit details
    Browse the repository at this point in the history
  2. Fix type errors

    rylnd committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    0800c29 View commit details
    Browse the repository at this point in the history
  3. Mock external dependency

    These tests now call out to the Notifications service (in a context)
    instead of our redux implementation.
    rylnd committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    8597df7 View commit details
    Browse the repository at this point in the history