kibana/x-pack/legacy
Ryland Herrick b7a534b1b1
[SIEM] Implement NP Plugin Setup (#54030)
* Set up our react app in the NP way

* Defines the setup() method for our UI plugin
* Renders the app in the NP way within our setup() method
* Defines a legacy file that invokes the plugin manually

Things seem to be mostly working; the app mounts with no immediate
errors, at least.

* Move files into NP structure

Our plugin function and class are both direct children of siem/public.
The app folder contains both our React app and the function to render
it.

* Register SIEM in the feature catalogue via NP format

Unfortunately, this can't live in the plugin for now because it doesn't
get invoked when we need it. For now, it's going to live in the same
spot, and once we're a real NP plugin we can move it.

* Eliminate usage of timezoneBrowser UI setting

This seems to be redundant with dateFormat:tz except that it always
returns a real timezone, not just a preference. By wrapping that logic
in our own hook, useTimeZone, we can remove this weird usage and stick
to the standard dateFormat and dateFormat:tz.

* Clean up tests for FormattedDate components

Mocks our simpler wrapping hooks rather than the entire UI Settings
module.

* Remove remaining uses of UI Settings mocks

These remaining tests can mock settings directly, or otherwise were
misusing the settings mocks to retrieve assertion values.

* Remove unnecessary intermediate `describe` blocks

They were not adding any information to the tests.

* Remove use of kibana version in client requests

We were previously passing this version all over the place for the sake
of our framework-specific request header. The sole advantage of supplying
such a header is that the client will receive an informative error modal
in the case of a version mismatch between the client and server.

We can successfully perform these requests with the `kbn-xsrf` header
instead. Long-term, we can use core.http.fetch to perform the requests
and auto-populate the version header, but it would be nicer to abstract
those requests to the framework level rather than threading the HTTP
client throughout the application.

* Remove newly added uses of kbnVersion

These happened on master in the meantime.

* Use helper to generate test assertion

Allows us to change the implementation of the empty string without
breaking the test.

* Remove guard from date formatting component

We're always going to get back usable values from these hooks; while the
user can unset the dateFormat in their settings, we'll still get an
empty string which is effectively the same as no formatting (as
evidenced in the tests).

* Remove default from byte formatting component

If the user has deleted this default, they presumably meant to do so and
we shouldn't supersede it.

* Refactor bytes formatting to allow use in our charts

We need a formatting function to use with our charts, so this splits out
a hook from the original react component, allowing our charts to be
formatted as specified in the user's UI settings.

* Refer to our constant for APP_ID

* Explicit return values for some UI Settings hooks

This forces accidental changes to the return value to be explicit.

* Remove use of ui/chrome in request header

This is an unnecessary use: kibana works the same no matter what
contents the `kbn-xsrf` header contains (as long as it's there).

* Mock UI Settings values in our TestProvider

When using our TestProvider components, we were previously relying on
platform's UISettings mocks instead of our own, more comprehensive ones.
This worked for the most part, and when we needed real settings we would
mock the UI Settings client manually.

When we removed some app code that defaulted UI Settings values when the
client did not return a value, tests that used TestProviders but also
relied on those defaults broke. This adds that behavior back,
and obviates the need for manual calls to jest.mock except when we're a)
not using TestProviders but b) overriding the platform mocks.

Also removes some of those unneeded uses.

* Remove unused import

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-01-07 13:20:57 -08:00
..
common Support 'enterprise' license type (#52273) 2019-12-17 15:43:19 +01:00
plugins [SIEM] Implement NP Plugin Setup (#54030) 2020-01-07 13:20:57 -08:00
server/lib move eslint rule override comments for code that moved around 2019-12-13 23:17:13 -07:00